!pr0
New CATALOG Interrupt......................Col. Paul L. Shetler
                                            Tripler AMC, Hawaii

Most of the routines I've seen to terminate a CATALOG listing involve patching in a routine that checks for a particular key input and adding code to do different actions, like aborting or single-stepping the catalog list.  Here is a modification I came up with that requires only a small change and no additional code.

This is the section of DOS that handles a new line in the CATALOG display:

               1000        .OR $AE2C
               1010 
AE2C- 4C 7F B3 1020        JMP $B37F    leave File Manager
AE2F- A9 8D    1030 NEWLN  LDA #$8D     carriage return
AE31- 20 ED FD 1040        JSR $FDED    MON.COUT
AE34- CE 9D B3 1050        DEC $B39D    line count
AE37- D0 08    1060        BNE .1
AE39- 20 0C FD 1070        JSR $FD0C    MON.RDKEY
AE3C- A9 15    1080        LDA #$15     count 21 lines
AE3E- 8D 9D B3 1090        STA $B39D    reset line count
AE41- 60       1100 .1     RTS

Line 1020 is really the end of the previous routine, but we're going to be borrowing it, so I'll show it here.  NEWLN is called every time the catalog list finishes a file name.

Notice that two bytes are wasted in lines 1030-1040.  Why do LDA #$8D, JSR $FDED, when JSR $FD8E does the same thing?  Two bytes may not sound like much, but in this case it's enough to work some magic!  Try replacing the above piece of DOS with this:

               1000        .OR $AE2C
               1010 
AE2C- 4C 7F B3 1020 EXIT   JMP $B37F    leave File Manager
AE2F- 20 8E FD 1030 NEWLN  JSR $FD8E    MON.CROUT
AE32- CE 9D B3 1040        DEC $B39D    line count
AE35- D0 0A    1050        BNE .1       return if not done
AE37- 20 0C FD 1060        JSR $FD0C    get a keypress
AE3A- 29 17    1070        AND #$17     the magic number
AE3C- F0 EE    1080        BEQ EXIT     abort CATALOG
AE3E- 8D 9D B3 1090        STA $B39D    new line count
AE41- 60       1100 .1     RTS

Slipping in that AND #$17, BEQ EXIT, has several effects:

!lm+3
!pp-3
1. Space Bar or Back Arrow will terminate the listing.
2. Forward Arrow will advance the listing one page (just like normal.)
3. The "A" key will advance the listing one line.
!lm-3
!pp0

And it all fits into the original space!  The other keys will have different effects, depending on the value left in the accumulator after AND #$17.  Most keys will advance the listing between 1-23 lines.

Try substituting other values for the $17 in line 1070.  Remember that the value of (Keypress AND Value) will be the new line count.  The catalog display will scroll up by that number of lines.  If the result is zero, the catalog display will end.  The maximum result is the same as the mask value, that is, 23 lines for a $17 mask.

[  My favorite mask value is $4F.  With that value SPACE still breaks the display, but now the numeral keys scroll up by the same number of lines, i.e., pressing the "1" key gives one more line, "2" shows two more names, and so on.  Also, the "O" (oh, not zero) key scrolls up by 79 lines, which usually means all the way to the end of the catalog....Bill  ]
